import { meshLog } from "../config";

//修改置顶状态的数据
export const saveStateById = (areasetDevs, id) => {
  //meshLog("修改参数:", areasetDevs);
  for (let i = 0; i < areasetDevs.length; i++) {
    if (areasetDevs[i].id === id) {
      areasetDevs[i].state = areasetDevs[i].state == 0 ? 2 : 0;
    }
  }
  meshLog("areasetDevs:", areasetDevs);
  return areasetDevs
}
//删除固定id的所有数据
export const deleteDataById = (areasetDevs, id) => {
  //meshLog("修改参数:", areasetDevs);
  let areasetDev = areasetDevs.filter(function (item) {
    return item.id !== id
  });
  return areasetDev
}

//传入id和是一个数组，找到这个ID下面对应的数据
export const getreplydataById = (id, data) => {
  //meshLog('data', data);
  let dataSetx = data
  if (data.length == 0) {
    return 0
  } else {
    let meshIforSet = dataSetx.filter((item) => {
      if (item.message_id == id) {
        return item
      }
    })
    if (meshIforSet.length == 0) {
      return false
    } else {
      let i = meshIforSet.length
      let replydate = meshIforSet[i - 1].info
      return replydate
    }

  }
}
